package de.szut.hh.MVC;

import javax.swing.JButton;

class ButtonView extends JButton implements PlusMinusListener {

	public static final int MAX_LIMIT =1;
	public static final int MIN_LIMIT =2;
	
	private int limitType;
	
	public ButtonView(String text, PlusMinusModel model, int _limitType){
		super(text);
		limitType = _limitType;
		valueChanged(model);
	}
	
	
	@Override
	public void valueChanged(PlusMinusModel model) {
		int limit;
		if (limitType==MAX_LIMIT){
			limit=model.getMax();
		}else{
			limit=model.getMin();
		}
		if (model.getCounter()==limit){
			setEnabled(false);
		}else{
			setEnabled(true);
		}
	}
}

